package springbootcache.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.stereotype.Service;
import springbootcache.bean.Employee;
import springbootcache.mapper.EmployeeMapper;

@CacheConfig(cacheNames = {"emp"})
@Service
public class EmployeeService {

    @Autowired
    EmployeeMapper employeeMapper;

    @Cacheable()
    public Employee getEmp(Integer id){
        System.out.println("id = "+ id);
        Employee employee = employeeMapper.getEmpByID(id);
        return employee;
    }
}
